package org.oimwrapper.connectors.common;

import com.thortech.util.logging.*;
import java.io.*;

import org.oimwrapper.connectors.*;

/**
 * Reloads the logging configuration on application servers that do not support 
 * automatic reloads.<p>
 *
 * This task expects the following parameters, in addition to the standard
 * parameters in the {@link OIMTaskBase} class.
 */
public class OIMReloadLogProperties extends OIMTaskBase {
    
	/**
	 * Default constructor.
	 */
	public OIMReloadLogProperties() {
		super("OIMWRAPPER.TASK");
	}

	/**
	 * This method is called by the scheduler to execute the task instance.
	 */
	public void execute() {
		try {
			String config = System.getProperty("XL.HomeDir") + File.separator + "config" + File.separator + "log.properties";
			Logger.initialize(config);
			logger.warn("Reloaded " + config);
		} catch (Exception e) {
			OIMExceptionHandler.handleException(logger, e, getClass());
		}
	}

	/**
	 * This method is called by the scheduler to stop a running task instance.
	 * 
	 * @return <code>true</code>
	 */
	public boolean stop() {
		return true;
	}
}